[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 execlp()                Execute Program Using Argument List and Path

 #include   <process.h>

 int        execlp(pathname, arg0,arg1,...,argn,NULL);

 char       *pathname;                   Path name of file to be executed
 char       *arg0,*arg1,...,*argn;       List of pointers to arguments

    execlp() operates identically to execl(), with one exception:  If
    'pathname' is not found as described in execl(), then execlp() will
    use the DOS PATH to continue the search for the path name.  With that
    single exception, the two functions are identical; see execl() for a
    complete description.

   -------------------------------- Example ---------------------------------

    The following statements transfer execution to the child process
    "child", and pass it the three arguments "CHILD", "arg1", and "arg2".
    "child", "child.com", or "child.exe" can be in the current directory,
    or any PATH directory:

           #include <process.h>    /* for 'execlp' */
           #include <stdio.h>      /* for 'printf' and 'NULL' */
           #include <errno.h>      /* for 'errno, 'ENOENT' and 'ENOMEM' */

           main()
           {
               execlp("child", "CHILD", "arg1", "arg2", NULL);
               /* only get here on an exec error */
               if (errno == ENOENT) {
                   printf("neither child nor child.exe found in current\n");
                   printf("  directory, or in any PATH directory\n");
               }
               else if (errno == ENOMEM)
                   printf("not enough memory to execute child\n");
               else
                   printf("error #%d trying to exec child\n", errno);
           }


See Also: execl() execlpe() spawnlpe() execvp() exec...()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson